function y = map(f, x)

%apply a function f to all elements of the vector or matrix x
n=size(x);
y = zeros(n);

for i=1:n(1)
    for j=1:n(2)
        y(i,j)=f(x(i,j));
    end
end

end